<?php
/********用户资料页面********/
if(!is_user_logged_in()) {
	wp_redirect(site_url()."/wp-login.php");
	exit;
}
global $wpdb, $post, $wp_query,$current_user,$userdata;
get_currentuserinfo();
$query_vars = $wp_query->query_vars;
//$pagenum = isset($query_vars['paged']) ? $query_vars['paged'] : 1;
$pagenum = isset( $_GET['pagenum'] ) ? intval( $_GET['pagenum'] ) : 1;
$comments_total = get_user_comments_count($userdata->ID);
$total_page = ceil($comments_total/20);
$current = ($pagenum-1)*20;
$args = array(
	'user_id' => get_current_user_id(),
	'status' => 'approve',
	'number' => 20,
	'offset' => $current
);
$coments_query = get_comments( $args );
?>

<div class="member_system">
    <div class="title_member"> 评论总数：<?php echo $comments_total;?></div>  
    <ul class="item-list">
	   <?php $check= "select * from ".$wpdb->prefix."comments where user_id='$userdata->ID' and comment_approved='1' limit $current,20 ";
            $coo = $wpdb->get_results($check); 	
            if(count($coo) > 0){
            foreach ($coo as $co) {
            $post_of_int=get_post($co->comment_post_ID );	
        ?>  	
            <li>
            <div class="user_list_title"  style="line-height:28px;" >
            <a href="<?php echo get_permalink($post_of_int->ID); ?>"> 
            <?php echo $post_of_int->post_title;?>
            </a>
            </div>
            </li>
      <?php }} ?>
    </ul>
</div>

<div class="pageBox" >
<div class="page"  align="center" >
  <?php
$pagination = paginate_links( array(
	'base' => add_query_arg( 'pagenum', '%#%' ),
	'format' => '',
	'prev_text' => '上一页',
	'next_text' => '下一页',
	'total' => $total_page,
	'current' => $pagenum
	)
);
if ( $pagination ) {
	echo $pagination;
}
?>  </div>
<div class="clear"></div>
</div>